package com.heima.day07.homework6;

/*
 * 6、【编号：707】 请定义一个描述矩形（MyRectangle）的
 * 类，* 包含宽和高两个属性，提供获取矩形周长（perimete
 * r）* 和面积（area）的方法。并编写测试类进行测试。*/
public class MyRectangle {
    private double width;
    private double high;

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getHigh() {
        return high;
    }

    public void setHigh(double high) {
        this.high = high;
    }

    public MyRectangle() {
    }

    public MyRectangle(double width, double high) {
        this.width = width;
        this.high = high;
    }

    public void perimeter() {
        System.out.println("宽是" + this.width + "厘米,高是" +
                this.high + "厘米的矩形周长是:" + 2 * (this.width + this.high));
    }

    public void area() {
        System.out.println("宽是" + this.width + "厘米,高是" +
                this.high + "厘米的矩形面积是:" + this.width * this.high);
    }
}

class Text {
    public static void main(String[] args) {
        System.out.println("采用无参构造函数:");
        MyRectangle mr = new MyRectangle();
        mr.setWidth(22);
        mr.setHigh(35);
        mr.perimeter();
        mr.area();
        System.out.println("采用全参构造函数:");
        MyRectangle mt = new MyRectangle(36, 66);
        mt.perimeter();
        mr.area();
    }
}